<?php

declare(strict_types=1);

namespace App\Robot\Amqp\Consumer;

use App\CustHub\Constants\ContactTaskCenterStatusConstants;
use App\CustHub\Constants\ContactTaskCenterTyperConstants;
use App\CustHub\Model\ChContact;
use App\CustHub\Model\ChContactTaskCenter;
use App\CustHub\Service\ChSendRecordService;
use App\Robot\Job\DelayedTaskJob;
use App\Robot\Job\SendRecordJob;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;
use Hyperf\Amqp\Result;
use Hyperf\AsyncQueue\Driver\DriverFactory;
use PhpAmqpLib\Message\AMQPMessage;
use function Hyperf\Collection\data_get;
use function Hyperf\Coroutine\co;

#[Consumer(exchange:"send_record", routingKey:"send_record", queue:"send_record", name:"sendRecord", nums:1)]
class SendRecordConsumer extends ConsumerMessage
{
    public function consumeMessage($data, AMQPMessage $message): Result
    {
        if(empty($data['recordData'])){
            return Result::DROP;
        }
        container()->get(ChSendRecordService::class)->addRecord($data);
        return Result::ACK;
    }


    public function isEnable(): bool
    {
        return \Hyperf\Support\env('AMQP_CONSUMER_ENABLE',false);
    }
}